package com.example.yls.demoa;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private ListView lvStu;
    private List<Student> stuList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        lvStu = findViewById(R.id.lv_stu);

        stuList = new ArrayList<>();

        initstuList();

        StuAdapter stuAdapter = new StuAdapter(this,stuList);
        lvStu.setAdapter(stuAdapter);

    }

    private void initstuList() {

        Student student1 = new Student(R.drawable.dog1,"小黄",4);
        Student student2 = new Student(R.drawable.dog2,"小黄",4);
        Student student3 = new Student(R.drawable.dog3,"小黄",4);
        Student student4 = new Student(R.drawable.dog4,"小黄",4);
        Student student5 = new Student(R.drawable.dog5,"小黄",4);

        stuList.add(student1);
        stuList.add(student2);
        stuList.add(student3);
        stuList.add(student4);
        stuList.add(student5);
        stuList.add(student1);
        stuList.add(student2);
        stuList.add(student3);
        stuList.add(student4);
        stuList.add(student5);
        stuList.add(student1);
        stuList.add(student2);
        stuList.add(student3);
        stuList.add(student4);
        stuList.add(student5);
        stuList.add(student1);
        stuList.add(student2);
        stuList.add(student3);
        stuList.add(student4);
        stuList.add(student5);

    }


}
